package cn.lingyangwl.agile.system.controller;

import cn.lingyangwl.agile.system.model.rqrs.diy.*;
import cn.lingyangwl.agile.system.model.rqrs.diy.DiyAppLinkUpdateReq;
import cn.lingyangwl.agile.system.model.rqrs.diy.DiyAppLinkResp;
import cn.lingyangwl.agile.system.service.DiyAppLinkService;
import cn.lingyangwl.framework.core.response.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 移动端链接
 * 
 * @author shenguangyang
 */
@Api(tags = "移动端菜单")
@RestController
@RequestMapping("/diy/appLink")
public class DiyAppLinkController {
    @Resource
    private DiyAppLinkService diyAppLinkService;

    @ApiOperation(value = "分页移动端菜单")
    @GetMapping("/list")
    public Resp<List<DiyAppLinkResp>> listLink(@Validated DiyAppLinkQueryReq req) {
        return Resp.ok(diyAppLinkService.listLink(req));
    }

    @ApiOperation(value = "通过id查找移动端菜单")
    @GetMapping("/get")
    public Resp<DiyAppLinkResp> getLink(@RequestParam(value = "id") Long id) {
        return Resp.ok(diyAppLinkService.getLink(id));
    }
  
    @ApiOperation(value = "保存移动端菜单")
    @PostMapping("/save")
    public Resp<?> saveLink(@Validated @RequestBody DiyAppLinkSaveReq req) {
        return Resp.ok(diyAppLinkService.saveLink(req));
    }
  
    @ApiOperation(value = "更新移动端菜单")
    @PostMapping("/update")
    public Resp<?> updateLink(@Validated @RequestBody DiyAppLinkUpdateReq req) {
        return Resp.ok(diyAppLinkService.updateLink(req));
    }
  
    @ApiOperation(value = "批量删除移动端菜单")
    @DeleteMapping("/batchDelete")
    public Resp<?> batchDeleteLink(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(diyAppLinkService.batchDeleteLink(ids));
    }
  
    @ApiOperation(value = "删除移动端菜单")
    @DeleteMapping("/delete")
    public Resp<?> deleteLink(@RequestParam(value = "id") Long id) {
        return Resp.ok(diyAppLinkService.deleteLink(id));
    }
}
